/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.server.main;

import com.server.database.DataEngine;
import com.server.database.UserInfo;

/**
 *
 * @author Administrator
 */
public class ChangePass {

    private String userName;
    private String userPassword;
    private String newPassword;
    private DataEngine dataEngine = DataEngine.getInstance();

    public ChangePass(String userName, String userPassword, String newPass) {
        this.userName = userName;
        this.userPassword = userPassword;
        this.newPassword = newPass;
    }

    public void response(ClientManager client) {
        UserInfo userInfo = dataEngine.getUserInfo(userName);
        if (userInfo.getUserPassword().equals(userPassword)) {
            dataEngine.changePass(userName, newPassword);
            client.sendMessage("CPASS|" + 1);
        } else {
            client.sendMessage("CPASS|" + 0);
        }
    }
}
